package hauwei.year2025.month4.day17;

import java.util.Arrays;
import java.util.Scanner;

public class Poker {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String []pokers=new String[n];
        int index=0;
        String line = scanner.nextLine();
        scanner.close();
        String[] numbers = line.split(" ");
        int count=numbers.length;
        for(int i=0;i<count;i++){
            String number=numbers[i];
            if(index-2<0){
                pokers[index++]=number;
            }else if (number.equals(pokers[index-1])&&number.equals(pokers[index-2])){
                index-=2;
            }else{
                pokers[index++]=number;
            }
        }
        for(int i=0;i<index;i++){
            System.out.print(pokers[i]);
            if(i!=index-1){
                System.out.print(" ");
            }
        }
        if(index==0){
            System.out.println("0");
        }
    }
}
